export default class SocketService {
  static instance = null
  static get Instance () {
    if (!this.instance) {
      this.instance = new SocketService()
    }
    return this.instance
  }

  ws = null
  connect () {
    if (!window.WebSocket) {
      return console.log('不支持')
    }
    this.ws = new WebSocket('ws://127.0.0.1:9999')
    this.ws.onopen = () => {
      console.log('连接成功')
    }
    this.ws.onclose = () => {
      console.log('连接失败')
    }
    this.ws.onmessage = () => {
      console.log('获取数据了')
    }
  }
}
